<?php

/**
 * @author Martin Pernica
 * @copyright 2008
 */
if (intval($_SESSION['rank']) >= $GLOBALS['page']->getPermission('content')) {
    include 'components' . DIR_SEP . 'com_content' . DIR_SEP . 'MainClass.php';

    $content = new com_content();
    $content->log = $log;

    $reserve_query = array('categories', 'page', 'sections');

    if (!empty($q[1]) and !in_array($q[1], $reserve_query)) {

        $content->getSingleArticle(intval($q[1]));

    } elseif (htmlspecialchars($q[1]) == 'categories' || htmlspecialchars($q[1]) ==
    'sections') {
        if (empty($q[2])) {

            if ($q[1] == "categories") {
                $content->getListOfCategories();
            } elseif ($q[1] == "sections") {
                $content->getListOfSections();
            }

        } else {

            if ($q[1] == "categories") {
                $content->getArticlesFromCategory(intval($q[2]), 50);
            } elseif ($q[1] == "sections") {
                $content->getCategoriesFromSection(intval($q[2]), 50);
            }


        }
    } else {
        $pageNum = (empty($q[2]) ? '1' : intval($q[2]));
        $rowsPerPage = 10;
        $offset = ((intval($pageNum) - 1) * intval($rowsPerPage));
        $content->getAllArticles($offset, $rowsPerPage);
    }

}else{
	echo '<h2>Čtení článků je povoleno od úrovně <strong>' . rank2text($GLOBALS['page']->
            getPermission('content')) . '</strong> !</h2>';
}
?>